package net.sunofbeach.blog.controller.portal;

import net.sunofbeach.blog.pojo.Plan;
import net.sunofbeach.blog.response.ResponseResult;
import net.sunofbeach.blog.services.IPlanService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/portal/plan")
public class PlanPortalApi {

    @Autowired
    private IPlanService planService;


    @PostMapping
    public ResponseResult postPlan(@RequestBody Plan plan) {
        return planService.postPlan(plan);
    }

    @GetMapping("/list/{page}/{size}")
    public ResponseResult listPlan(@PathVariable("page") int page,
                                    @PathVariable("size") int size) {
        return planService.listPlan(page, size);
    }

    @GetMapping("/list/{time}")
    public ResponseResult listPlan(@PathVariable("time") String time) {

        return planService.listPlanByTime(time);
    }
}
